package com.handu.luna.core.domain.promotion;


import javax.persistence.Entity;
import javax.persistence.PostLoad;
import javax.persistence.Transient;

import com.handu.luna.core.domain.goods.Goods;

@Entity
public class CreditPromotionGoods extends Promotion {
	
	private long creditPromotionId;
	private long goodsId;
	private Integer credit;
	private Integer multiple;

    @Transient private Goods goods;
    @Transient private CreditPromotion creditPromotion;

    @PostLoad
    public void init(){
        if(goodsId != 0) {
            goods = context.getGoodsRepository().findOne(goodsId);
        }
        if(creditPromotionId != 0) {
            creditPromotion = context.getCreditPromotionRepository().findOne(creditPromotionId);
        }
    }

	public long getCreditPromotionId() {
		return creditPromotionId;
	}
	public void setCreditPromotionId(long creditPromotionId) {
		this.creditPromotionId = creditPromotionId;
	}
	public long getGoodsId() {
		return goodsId;
	}
	public void setGoodsId(long goodsId) {
		this.goodsId = goodsId;
	}

    public Goods getGoods() {
        return goods;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    public CreditPromotion getCreditPromotion() {
        return creditPromotion;
    }

    public void setCreditPromotion(CreditPromotion creditPromotion) {
        this.creditPromotion = creditPromotion;
    }

    public Integer getCredit() {
        return credit;
    }

    public void setCredit(Integer credit) {
        this.credit = credit;
    }

    public Integer getMultiple() {
        return multiple;
    }

    public void setMultiple(Integer multiple) {
        this.multiple = multiple;
    }
}
